%!TEX program = xelatex
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt,t,aspectratio=169,mathserif]{beamer}
%Other possible values are: 1610, 149, 54, 43 and 32. By default, it is to 128mm by 96mm(4:3).
%run XeLaTeX to compile.

\input{wang-slides-preamble.tex}

\begin{document}

\title{第9章：偏微分方程：伪谱方法}
%(1.1-1.2) 
%\institute{上海立信会计金融学院}
\author{JMS LQW}
%\date{2021年3月12日}

\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[fragile=singleslide]{6.1.1. }
\begin{frame}{目录 }

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{enumerate}\itemsep0.1cm
\item[9.1.]  初边值问题
\item[9.2.]  直线法
\item[9.3.]  有限差分：空间导数方法
\item[9.4.]  周期问题的谱技术：空间导数方法
\item[9.5.]  空间周期问题的初值问题
\item[9.6.]  非周期问题的谱技术
\item[9.7.]  f2py 概述
\item[9.8.]  f2py 真实案例
\item[9.9.]  伯格斯方程
\end{enumerate}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.1. 偏微分方程的数值求解 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：数学物理方程研究多元函数 $u=u(t,x)$, 在数值求解中，对时间变量 $t$ 和空间变量 $x$ 分别是如何处理的？ 

\item  答：对时间变量的积分，用直线法，对空间变量的积分，用有限差分法，或谱方法。
按空间变量的特征，分成两种情况：
\begin{enumerate}
\item  未知函数对空间变量有周期性：傅立叶方法。
\item  未知函数对空间变量没有周期性：切比雪夫变换。
\end{enumerate}


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.1. 伯格斯方程 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

%\item  问：什么是伯格斯方程？

\item  应用场景：流体力学、非线性声学、气体动力学、交通流等。
$$u_t = -uu_x + \mu u_{xx}. $$

\item  变量和参数的含义：
\begin{enumerate}
\item  $u =$ 流体的速度
\item  $\mu =$ 运动的粘性
\item  $x =$ 空间变量
\item  $t = $ 时间变量
\end{enumerate}

\item  方程右边的含义：
\begin{enumerate}
\item  第一项 $-uu_x$ 表示某种守恒定律导致的对流
\item  第二项 $\mu u_{xx}$ 表示类似热方程的扩散
\end{enumerate}

%\item  Burgers' equation or Bateman–Burgers equation is a fundamental partial differential equation occurring in various areas of applied mathematics, such as fluid mechanics, nonlinear acoustics, gas dynamics, and traffic flow. 

%\item  The equation was first introduced by Harry Bateman in 1915 and later studied by Johannes Martinus Burgers in 1948. 

%\item  For a given field $u(x,t)$ and diffusion coefficient (or kinematic viscosity, as in the original fluid mechanical context) $\nu$, the general form of Burgers' equation (also known as viscous Burgers' equation) in one space dimension is the dissipative system: When the diffusion term is absent (i.e. $\nu=0$), Burgers' equation becomes the inviscid Burgers' equation: which is a prototype for conservation equations that can develop discontinuities (shock waves).

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.1. 初边值问题 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：伯格斯方程的初边值条件是怎样的？

\item  答：设时间区间为 $t\in [0,T]$, 空间区间为 $x\in [a,b]$. 
\begin{enumerate}
\item  初始条件为 $u(0,x)=f(x), \,\,\, x\in [a,b]$. 
\item  边界条件为 $u(t,a)=g_1(t), \,\, u(t,b)=g_2(t), \,\, 0\le t\le T$. 
\end{enumerate}

\item  答：设时间区间为 $t\in [0,T]$, 设空间无边界，即 $x\in (-\infty,\infty)$. 
\begin{enumerate}
\item  初始条件为 $u(0,x)=f(x), \,\,\, x\in (-\infty,\infty)$. 
\item  边界条件无。
\end{enumerate}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.2. 直线法 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：什么是直线法？

\item  答：
\begin{enumerate}
\item  将偏微分方程写成 $u_t = \mathcal{S}[u,u_x,u_{xx}]$ 的形式。
\item  思路：对每个 $x\in [a,b]$, 计算上述右边，得到一个关于 $t$ 的常微分方程。
\item  实际：将区间 $[a,b]$ 进行划分，估计空间导数 $u_x$ 与 $u_{xx}$, 计算上述右边。
\end{enumerate}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.3. 有限差分空间导数 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：将空间区间分成 $N$ 等分，即 $a = x_0 < x_1 < x_2 < \cdots < x_N = b$, 间隔 $dx=(b-a)/N$. 
如何通过 $u(t,x)$ 的值，来估计空间导数 $u_x(t,x)$ 与 $u_{xx}(t,x)$ 的值？

\item  答：
\begin{eqnarray*}
u_x(t,x) &=& \frac{u(t,x_{n+1}) - u(t,x_{n-1})}{2dx} + O(dx^2), \\
u_{xx}(t,x) &=& \frac{u(t,x_{n+1}) -2u(t,x_n) + u(t,x_{n-1})}{dx^2} + O(dx^2). 
\end{eqnarray*}


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.3. 有限差分法的计算步骤 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{enumerate}
\item  在 $t=0$ 时，根据有限差分公式，估计空间导数，计算所有的 $u,u_x,u_{xx}$. 
\item  用欧拉方法，求解这些关于 $t$ 的常微分方程初值问题，如绿线所示：
$$u_t = \mathcal{S}[u,u_x,u_{xx}].$$
\item  求出红点所在的函数值。
\item  在 $t=0+dt$ 时，根据有限差分公式，估计空间导数，重复上述步骤。
\end{enumerate}




\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.7\textheight, width=0.7\textwidth]{pic/fig-9-3.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.3. 有限差分法的缺点 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：在每个常微分方程初值问题的求解中，如果使用前向欧拉方法，为了确保数值解是收敛的，那么时间步长 $dt$ 需要满足什么条件？

\item  答：需要满足条件 $dt < C dx^2$, 这增加了计算时间。


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4. 周期问题的谱技术：空间导数方法 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  设未知函数 $u(t,x)$ 关于空间变量 $x$ 具有周期 $2\pi$. 

\item  设 $\tilde{u}(t,k)$ 是 $u(t,x)$ 关于 $x$ 的傅立叶变换，则 $u_x(t,x)$ 关于 $x$ 的傅立叶变换是 $(ik)\tilde{u}(t,k)$, 
$u_{xx}(t,x)$ 关于 $x$ 的傅立叶变换是 $(ik)^2\tilde{u}(t,k)$. 

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4.  DFT 的运算复杂度 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：分析 DFT 的运算复杂度。
\begin{enumerate}
\item  矩阵乘法
\item  快速傅立叶变换方法
\end{enumerate}

\item  参考文献：
\begin{enumerate}
\item  Boyd, J.P., Chebyshev and Fourier Spectral Methods, second edition, Dover, 2001. 
%\item  
\end{enumerate}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4. 一个例子 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：计算下述函数的导数，以此比较有限差分法和谱方法。
 $$f(x) = \exp(\sin(x)),\,\, 0\le x\le 2\pi.$$ 

\item  答：在 scipy.fftpack 模块中，函数 diff 使用谱方法计算导数。

\item  问：scipy.fftpack 中的 diff 函数是怎么编写的？



\end{itemize}

\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码1/2：
\begin{python}
import numpy as np
from scipy.fftpack import diff

def fd(u):
    '''Return 2*dx finite difference x-derivative of u. '''
    ud=np.empty_like(u)
    ud[1:-1]=u[2: ]-u[ :-2]
    ud[0]=u[1]-u[-1]
    ud[-1]=u[0]-u[-2]
    return ud
\end{python}

\end{itemize}

\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码2/2：

\begin{python}
for N in [4,8,16,32,64,128,256]:
    dx=2.0*np.pi/N
    x=np.linspace(0,2.0*np.pi,N,endpoint=False)
    u=np.exp(np.sin(x))
    du_ex=np.cos(x)*u
    du_sp=diff(u)
    du_fd=fd(u)/(2.0*dx)
    err_sp=np.max(np.abs(du_sp-du_ex))
    err_fd=np.max(np.abs(du_fd-du_ex))
    print('N=%d,err_sp=%.4e err_fd=%.4e'%(N,err_sp,err_fd))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{table}[ht]
\centering
\caption{求导数：理论值与数值计算的比较}
\begin{tabular}{|c|c|c|}\hline
小区间个数 & 谱方法的误差 & 有限差分方法的误差 \\ \hline  
N=4 & 1.75e-01 & 2.52e-01 \\ \hline 
N=8 & 4.32e-03 & 3.40e-01 \\ \hline 
N=16 & 1.76e-07 & 9.36e-02 \\ \hline 
N=32 & 4.00e-15 & 2.58e-02 \\ \hline  
N=64 & 9.88e-15 & 6.51e-03 \\ \hline  
N=128 & 2.20e-14 & 1.63e-03 \\ \hline  
N=256 & 5.80e-14 & 4.09e-04 \\ \hline  
\end{tabular}
\end{table}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.4.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.7\textheight, width=0.7\textwidth]{pic/fig-9-4.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5. 空间周期问题的初值问题 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解偏微分方程的初值问题
$$u_t = -2\pi u_x, \,\, u(0,x) = \exp(\sin(x)),\,\, 0\le x\le 2\pi, \,\, 0\le t\le 64\pi. $$


\item  答：精确解为 $$u(t,x) = \exp(\sin(x-2\pi t)).$$ 


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码1/5：

\begin{python}
import numpy as np
from scipy.fftpack import diff
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def u_exact(t,x):   #定义精确解
    return np.exp(np.sin(x-2*np.pi*t))

def rhs(u,t):    #定义常微分方程的右边
    return -2.0*np.pi*diff(u)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码2/5：

\begin{python}
N=8
x=np.linspace(0,2*np.pi,N,endpoint=False)
u0=u_exact(0,x)    # 定义初值条件
t_initial=0.0
t_final=64*np.pi
t=np.linspace(t_initial,t_final,51)    #时间区间分成50等分
sol=odeint(rhs,u0,t,mxstep=500)    #同时求解很多初值问题

u_ex=u_exact(t[-1],x)    #精确解在时间右端点的函数值
err=np.max(np.abs(sol[-1,: ]-u_ex))   #在时间右端点的误差
print('With %d Fourier nodes the final error = %g' %(N,err))

\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码3/5：

\begin{python}
fig=plt.figure()
ax=Axes3D(fig)
t_gr,x_gr=np.meshgrid(x,t)
ax.plot_surface(t_gr,x_gr,sol,cmap='viridis')
ax.elev,ax.azim=60,-140
ax.set_xlabel('x')
ax.set_ylabel('t')
ax.set_zlabel('u')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.7\textheight, width=0.7\textwidth]{pic/fig-9-5.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码4/5：

\begin{python}
fig2=plt.figure()
bx=fig2.add_subplot(111)
bx.plot(x,u_ex,'b.-',label='exact solution')
bx.plot(x,sol[-1,: ]+0.1,'r.-',label='numerical solution + 0.1')
bx.set_xlabel('x')
bx.set_ylabel('u(t_final,x)')
bx.legend()
bx.set_title('exact u(tn,x) and numerical u(tn,x)')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.7\textheight, width=0.7\textwidth]{pic/fig-9-5-2.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  代码5/5：

\begin{python}
fig3=plt.figure()
cx=fig3.add_subplot(111)
for k in range(5):
    cx.plot(x,sol[k*2,: ],'.-')
cx.set_xlabel('x')
cx.set_ylabel('u(t,x)')
cx.set_title('u(t,x) for t=t0,t1,t2,t3,t4')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.5.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.7\textheight, width=0.7\textwidth]{pic/fig-9-5-3.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.6. 非周期问题的谱技术 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：考虑下述函数，设区间均匀划分，验证插值多项式序列并不收敛，
$$u(x) = \frac{1}{1+25x^2}, \,\, 0\le x\le 1. $$

\item  答：


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.6.  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：什么是切比雪夫网格节点？

\item  答：下述定义的函数序列 $\{f_N(x)\}$ 一致收敛到 $f(x)$. 

\begin{enumerate}
\item  取 $[0,\pi]$ 上的均匀节点 $\theta_k=k\pi/N, k\in [0,N]$. 
\item  设 $x_k=-cos(\theta_k)$ 与 $x=-\cos\theta$, 定义 
$$Q_k(x) = \frac{(-1)^k}{Nc_k} \frac{\sin\theta\sin(N\theta)}{(\cos\theta_k-\cos\theta)}. $$
其中 $c_0=c_N=2, c_k=1,1\le k\le N-1$. 
\item  定义多项式 $$f_N(x) = \sum\limits_{k=0}^{N} f(x_k) Q_k(x). $$
\end{enumerate}


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.7. f2py 概述 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：什么是 f2py?

%\item  答：


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.8. f2py的真实案例  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：实现下述文献中描述的切比雪夫转换工具。  

Fornberg, B. A Practical Guide to Pseudospectral Methods, Cambridge, 1995. 

%\item  答：


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{9.9. 使用示例：伯格斯方程 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求下述方程的数值解
$$u_t = -uu_x + \mu u_{xx}, \,\, -2\le t\le 2, \,\, -1\le x\le 1. $$
使用 kink 精确解用来比较数值解，$$u(t,x) = c\left[ 1+\text{tanh}\left( \frac{c}{2\mu} (ct-x)\right)\right]. $$


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[fragile=singleslide]{9.7.  }
%%\begin{frame}{}
%
%\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%%每页详细内容
%
%\begin{itemize}
%
%\item  问：
%
%\item  答：
%
%
%\end{itemize}
%
%\end{frame}
%
%
%
%




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[fragile=singleslide]{1.20. }
\begin{frame}{参考文献}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{thebibliography}{99}

\bibitem{stewart-en} John M. Stewart. \emph{Python for Scientists}. Second Edition. Cambridge University Press. 2017. 
\bibitem{stewart-cn} 约翰.M.斯图尔特(著). 江红.余青松(译). \emph{Python科学计算}，机械工业出版社，2019年8月第1版。

\bibitem{sauer-en} Timothy Sauer. \emph{Numerical Analysis}. Third Edition. Pearson. October 2017. 
\bibitem{sauer} Timothy Sauer(著).裴玉茹.马赓宇(译). \emph{数值分析}. 机械工业出版社. 2018年8月第1版.     

\end{thebibliography}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}


